package com.example.springboot_demo.order;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.lang.reflect.Type;

/**
 * @BelongsProject: springboot_demo
 * @BelongsPackage: com.example.springboot_demo.order
 * @Author: 江岸
 * @CreateTime: 2021-06-07 09:46
 * @Description: 第一个阶段
 */
class SpringState extends AbstractSate{

    public SpringState(AbstractSate abstractSate){
        context = abstractSate.context;
        name = ActionEnum.SUMMER.getName();
    }
    public SpringState(){
    }
    @Override
    public void fun() {
        System.out.println("第一阶段任务");
        System.out.println(context.getOrder());
        this.context.setState(new SummerState(this));
        service.update(context.getOrder());
    }
}
class SummerState extends AbstractSate{
    public SummerState(AbstractSate abstractSate){
        context = abstractSate.context;
        name = ActionEnum.SUMMER.getName();
    }
    public SummerState(){
    }
    @Override
    public void fun() {
        System.out.println("第二阶段任务");
        System.out.println(context.getOrder());
        this.context.setState(new FallState(this));
    }
}
class FallState extends AbstractSate{
    public FallState(AbstractSate abstractSate){
        context = abstractSate.context;
        name = ActionEnum.SUMMER.getName();
    }
    public FallState(){
    }
    @Override
    public void fun() {
        System.out.println("第三阶段任务");
        System.out.println(context.getOrder());
        this.context.setState(new WinterState(this));
    }
}
class WinterState extends AbstractSate{
    public WinterState(AbstractSate abstractSate){
        context = abstractSate.context;
        name = ActionEnum.SUMMER.getName();
    }
    public WinterState(){
    }
    @Override
    public void fun() {
        System.out.println("第四阶段任务,显示已完成状态");
        System.out.println(context.getOrder());
    }
}
